<div class="nav-sub w1180">
	<ul class="zoom">
		<li><a  href="/crm/financial/index">结算管理</a></li>
		<li><a  class="on" href="/crm/financial/list">账户流水</a></li>
	</ul>
</div>
<div class="main-ct w1180">
	<div class="top-bar">
		<div class="custom-search">
			<label>用户名<input type="text" class="tp-txt" id="user_name"></label>
			<label>用户编号<input type="text" class="tp-txt" id="user_uid"></label>
			<label>开始时间<input type="text" class="tp-txt" id="start_time" onFocus="WdatePicker({isShowClear:false,readOnly:true})"></label>
			<label>结束时间<input type="text" class="tp-txt" id="end_time" onFocus="WdatePicker({isShowClear:false,readOnly:true})"></label>
			<a href="javascript:search();" class="btn-cs btn-search ml5">查 询</a>
			<a href="javascript:exportData();" class="btn-cs btn-green ml5">输出报表</a>
		</div>
		
	</div>
<div id="list-table"></div>
</div>
<script src="/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    var user_uid = $("#user_uid").val();
    var user_name = $("#user_name").val();
    var start_time = $("#start_time").val();
    var end_time = $("#end_time").val();
    var page = 1;
    
    $(document).ready(function(){
    	ajaxListTable();
    });
    
    function search(){
    	user_uid = $("#user_uid").val();
    	user_name = $("#user_name").val();
    	start_time = $("#start_time").val();
    	end_time = $("#end_time").val();
    	if(start_time != '' && end_time <= start_time){
    		alert('结束时间不可大于等于开始时间');
    		return false;
        }
    	ajaxListTable();
    }

    function exportData(){
    	user_uid = $("#user_uid").val();
    	user_name = $("#user_name").val();
    	start_time = $("#start_time").val();
    	end_time = $("#end_time").val();
		
    	if(start_time != '' && end_time <= start_time){
    		alert('结束时间不可大于等于开始时间');
    		return false;
        }
    	
    	window.location.href="/crm/financial/export?"+ 'user_uid=' + user_uid + "&user_name=" + user_name + "&start_time=" + start_time + "&end_time=" + end_time;
    }
    
   
    function ajaxListTable(){
    	$.ajax({
            type: "post",
            url: "<?php echo $this->url('crm/financial',
                array('action'=>'ajax-financial-list'));?>",
            dataType:'html',
            data: { "user_uid": user_uid,
                	"user_name": user_name, 
                	"start_time": start_time,
                	"end_time": end_time, 
    				"page":page
    		},
            cache: false,
            timeout:10000, 
            error: function(){
              	 alert('请求超时，请重新操作');
               	 isPost = false;
                 return false; 
             }, 
            success: function(html){
            	$("#list-table").html(html);
            }
        });
    }

</script>